package com.zeus.data.jdbc;

import okhttp3.OkHttpClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @author magic
 * @date 2018/9/5/005 10:35
 * @version 1.0
 * Description OkHttpAutoConfiguration
 */
@Configuration
public class OkHttpAutoConfiguration {

    @Bean
    @ConditionalOnProperty(prefix = "zeus.http", name = "enabled", havingValue = "true")
    public OkHttpClient httpClient(){
        OkHttpClient client = new OkHttpClient
                .Builder()
                .connectTimeout(5,TimeUnit.SECONDS)
                .readTimeout(2,TimeUnit.SECONDS)
                .writeTimeout(2,TimeUnit.SECONDS)
                .build();
        return  client;
    }

}
